<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>resize事件案例</title>
    <style>
        /* 必须加上此css样式，js才能获取到clientHeight */
        html,body {
            width: 100%;
            height: 100%;
        }
    </style>
    <script>
        function winChange() {
            winWidth = document.body.clientWidth;
            winHeight = document.body.clientHeight;
            alert('窗口大小发生改变，宽：'+winWidth, "高:" +winWidth);
        }
    </script>
</head>
<body onresize="winChange()">
    
</body>
</html>